<?php namespace Admin\Controller;
class BrandController extends CommonController{
	protected $db;
	public function __construct(){
		$this->db= new \Common\Model\Brand;
		parent::__construct();
	}
	
	public function index(){
		$data = $this->db->get();
		View::with("data",$data);
	   View::make();
	}
	//添加类型
	public function addBrand(){
		if(IS_POST){
			if(!$this->db->store()){
			View::error($this->db->getError());
		   }else{
			View::success("添加成功",U('Brand/index'));
		   }
		}
		
		View::make();
	}
	//编辑
	public function edit(){
		$bid =Q("get.bid",0,"intval");
		$olddata = $this->db->where("b_id",$bid)->first();
		View::with("olddata",$olddata);
		if(IS_POST){
			if(!$this->db->edit()){
			View::error($this->db->getError());
		   }else{
			View::success("编辑成功",U('Brand/index'));
		   }
		}
		View::make();
	}
	//删除
	public function del(){
		$bid =Q("get.bid",0,"intval");
	}
}
